<?php

namespace App\Models;

use Illuminate\Notifications\Notifiable;
use Illuminate\Support\Facades\DB;
use Laravel\Passport\HasApiTokens;
use Illuminate\Foundation\Auth\User as Authenticatable;
use Spatie\Permission\Traits\HasRoles;
use App\Notifications\ResetPasswordNotification;
use App\Common\ConstCode;
class Category extends Authenticatable
{

    use HasApiTokens,Notifiable;


    protected $table = 'category';
    protected $fillable = ['id','name'];

    public    $timestamps = false;
    protected $primaryKey = 'id';


    public function lists(){
        $data['scene']=DB::table('category')->where(['status'=>ConstCode::YES,'type'=>1])->select($this->fillable)->get()->toArray();
        $data['prop']=DB::table('category')->where(['status'=>ConstCode::YES,'type'=>2])->select($this->fillable)->get()->toArray();
        $data['bubble']=config('cartoontag.NEW_BUBBLE');
        $data['role']=config('cartoontag.NEW_ROLE_CATEGORY');

        return $data;
    }

    public function tags($data){
        $res=array();
        switch ($data['category']){
            case '1':
                $res=DB::table('category')->where(['status'=>ConstCode::YES,'type'=>1])->select($this->fillable)->get()->toArray();
                break;
            case '3':
                $res=DB::table('category')->where(['status'=>ConstCode::YES,'type'=>2])->select($this->fillable)->get()->toArray();
                break;
            case '2':
                switch ($data['type']){
                    case '1':
                        $res=config('cartoontag.ROLE_HAIR');
                        break;
                    case '2':
                        $res=config('cartoontag.FACE');
                        break;
                    case '3':
                        $res=config('cartoontag.EXPRESSION');
                        break;
                    case '4':
                        $res=config('cartoontag.CLOTH');
                        break;
                    default:
                        break;
                }

            default:
                break;


        }

        return $res;
    }


}
